package com.controller;

import com.entity.CatAsk;
import com.service.CatAskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CatAskController {

    @Autowired
    CatAskService catAskService;

    @RequestMapping("/CatAskAdd")
    public String AddCatAsk(@RequestBody CatAsk catAsk){
        int i = catAskService.AddCatAsk(catAsk);
        return i > 0 ? "success" : "error";
    }

    @RequestMapping("/CatAnswerAdd")
    public String AddCatAnswer(@RequestBody CatAsk catAsk){
        int i = catAskService.AddCatAnswer(catAsk);
        return i > 0 ? "success" : "error";
    }

    @RequestMapping("/AllCatAsk")
    public List<CatAsk> AllCatAsk(){
        List a = catAskService.AllCatAsk();
        return a;
    }

    @RequestMapping("/ShowAnswer")
    public List<CatAsk> ShowAnswer(String cquestionid){
        List a = catAskService.ShowAnswer(cquestionid);
        return a;
    }

}
